using System;
using System.Runtime.Serialization;

namespace Lync.Widget.Library.ServiceHelpers
{
	[DataContract]
	[KnownType(typeof(MessageListServiceCallResponse))]
    [KnownType(typeof(GroupMessageListServiceCallResponse))]
	public class ServiceCallResponse
	{
		[DataMember]
		public bool HasError { get; set; }

		// hack to get the enum string return in json format
		[DataMember(Name = "ErrorCode")]
		public string ErrorCodeString { get; private set; }

		public ErrorCode ErrorCode
		{
			get
			{
				return (ErrorCode)Enum.Parse(typeof(ErrorCode), ErrorCodeString);
			}
			set
			{
				ErrorCodeString = value.ToString();
			}
		}

		[DataMember]
		public string ErrorMessage { get; set; }
	}

	public enum ErrorCode
	{
		NoError = 0,
		SessionError = 1, // a fatal error that causes the session to be destroyed
		SingleCallError = 2 //an error that caused a single service call to fail, but that doesnt destroy the session.
	}
}